﻿using Basic.FlowRemoteModel.Flow;
using Basic.FlowRemoteModel.Flow.Model;
using Basic.FlowService.Interface;
using WeDonekRpc.Client.Interface;

namespace Basic.FlowService.RpcEvent
{
    internal class FlowEnableEvent : IRpcApiService
    {
        private readonly IFlowEnableService _Service;

        public FlowEnableEvent ( IFlowEnableService service )
        {
            this._Service = service;
        }
        public EnableFlowResult CheckFlow ( CheckFlow obj )
        {
            bool res = this._Service.CheckFlow(obj.Id, out ErrorNode[] error);
            return new EnableFlowResult
            {
                Errors = error,
                IsError = res == false
            };
        }
        public EnableFlowResult EnableFlow ( EnableFlow obj )
        {
            bool res = this._Service.Enable(obj.Id, out ErrorNode[] error);
            return new EnableFlowResult
            {
                Errors = error,
                IsError = res == false
            };
        }
    }
}
